<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="__STATIC__/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="__STATIC__/jquery-2.1.3.js"></script>
<script src="__STATIC__/bootstrap/js/bootstrap.min.js"></script>
<script src="__STATIC__/bootstrap/b-date/bootstrap-datetimepicker.min.js"></script>
<script src="__STATIC__/bootstrap/b-date/bootstrap-datetimepicker.zh-CN.js"></script>
<link href="__STATIC__/bootstrap/b-date/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<css file='__ADMIN_PUBLIC__/css/public.css' />
<style>
body{font-family:'微软雅黑'}
a{cursor:pointer;padding:3px 3px;}
h3{margin: 15px 0;}
.mt20{margin-top:20px;}
.mr20{margin-right: 20px;}
.nav.nav-tabs li{margin:0;padding:0;}
.nav.nav-tabs li a{font-size:16px;font-weight:bold;}
.nav.nav-pills li a{padding:6px 12px;}
.fs16{font-size:16px;}
.fr{float:right;}
.page span{padding:3px 6px;}
.handle a {border-right: 1px solid #bbb; padding: 0 6px;}
.input-group {display: inline-table;float: left!important;}
.downbutton{float: right;}
</style>
</head>
<body>
    <div class="col-md-12">
    	<h3>用户列表</h3>
    </div>
    <div class="col-md-12">
	        <form action="{:U('/Admin/User/user_list')}" method="post">
		        <span>
		        	<div id="sdtp" class="col-md-2 input-group date mr20">
							<input type="text" class="form-control" id="atime" name="atime" value="{$atime}" placeholder="注册开始时间" readonly>
							<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
					</div>
					<div id="edtp" class="col-md-2 input-group date mr20">
							<input type="text" class="form-control" id="aetime" name="aetime" value="{$aetime}" placeholder="注册结束时间" readonly>
							<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
					</div>
					<select class="input-group mr20" name="sex" id="sex" value="{$sex}">
						<option value="0" id="default">性别</option>
						<option value="1" id="man">男</option>
						<option value="2" id="women">女</option>
						<option value="3" id="secury">保密</option>
					</select>
					
		        	<input type="text" name="search" id="search" value="{$search}" class="col-md-3"  placeholder="请输入名字，手机号，支持模糊查询" />
		        </span>
		        <button class="btn btn-success col-md-1 " type="submit" style="margin: 0 20px;" />搜索</button>
		    </form>
		    <script>
						//根据返回数据，改变性别初始值
						  var sexvalue = {$sex}0;
						  if(sexvalue == 00){$('#default').attr('selected','selected');}
						  if(sexvalue == 10){$('#man').attr('selected','selected');}
						  if(sexvalue == 20){$('#women').attr('selected','selected');}
						  if(sexvalue == 30){$('#secury').attr('selected','selected');}
			</script>
	    </div>
    <div class="col-md-12 mt20">
        <table class="table table-striped" style="text-align: center;">
            <tr>
                <th>用户名字</th>
                <th>手机号</th>
                <th>性别</th>
                <th>注册时间</th>
                <th>上次登录时间</th>
                <th style="padding-left: 14px;">操作</th>
            </tr>
            <notempty name="user">
            <foreach name='user' item='v'>
            <tr>
            	<td>{$v.nickname}</td>
                <td>{$v.phone}</td>
                <td><?php echo (intval($v['sex'])==3) ? '保密' : (intval($v['sex']) == 1 ? '男' : '女'); ?></td>
                <td>{$v.rtime|date='m-d H:i',###}</td>
                <td>{$v.ltime|date='m-d H:i',###}</td>
                <td>
                 	<a href="{:U('User/user_info', array('id' => $v['id']))}">详细信息</a>
                </td>
            </tr>
            </foreach>
            <else/>
            <tr>
            	<td colspan="7" class="text-center">暂无数据！！！</td>
            </tr>
            </notempty>
        </table>
    </div>
 <div class="text-align-center col-md-12">
 <div class="text-center page col-md-10">{$page}</div>
 <button type="button" class="btn btn-primary" id="download" name="download" class="downbutton">下载选定用户资料</button>
 </div>
 <script>
  
 	// 初始化开始时间控件
			function initSdtp() {
					$('#sdtp').datetimepicker({
							language: 'zh-CN',
							format: "yyyy-mm-dd",
							minView:2,
							todayBtn: 1,
							autoclose: 1,
							forceParse: 1,
							pickerPosition: "bottom-right"
						})
						.on('changeDate', function(ev) {
							$('#atime_err').hide();
							$('#aetime_err').hide();
							initEdtp(new Date(Date.parse($('#atime').val().replace(/-/g, '/'))));
						});
				}
				// 初始化结束时间控件
			function initEdtp() {
				$('#edtp').datetimepicker({
						language: 'zh-CN',
						format: "yyyy-mm-dd",
						minView:2,
						autoclose: 1,
						forceParse: 1,
						startView: 2,
						pickerPosition: "bottom-left"
					})
					.on('changeDate', function(ev) {
						$('#aetime_err').hide();
					});
			}
			initSdtp();
			initEdtp();
			$('#download').click(function(){ 	
				var atime = $('#atime').val(),
				    aetime = $('#aetime').val(),
				    sex = $('#sex').val(),
				    search = $('#search').val();
				 console.log(atime+'-'+aetime+'-'+sex+'-'+search);
				location.href="__ROOT__/Admin/User/out_user_lit/atime/"+atime+"/aetime/"+aetime+"/sex/"+sex+"/search/"+search;
//				 $.post('{:U(User/out_user_lit)}',{atime:atime,aetime:aetime,sex:sex,search:search},function(res){
//				 	if(res){
//				 	swal('下载成功');
//				 	}
//				 });
			});
 </script>
</body>
</html>